[python] Fix read_paimon ArrowInvalid on PK tables with single-snapshot data#7820
Merged
JingsongLi merged 1 commit intoMay 12, 2026
Merged
Conversation
…ible splits Table.from_batches rejects batches whose schema differs from the declared schema in the nullable bit — PK columns are marked NOT NULL in the Paimon schema but the Parquet reader may produce nullable fields on certain pyarrow versions. Use Table.cast to align the batch schema before yielding to Ray, which is a zero-copy metadata-only operation for nullable diffs. This fixes read_paimon crashing with ArrowInvalid on PK tables where all splits are raw-convertible (e.g. single-snapshot data with no overlapping keys).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
read_paimon()crashes withpyarrow.lib.ArrowInvalidwhen readinga primary-key table whose data consists of a single snapshot (all
splits are raw-convertible). The issue is in
RayDatasource._get_read_task:schemacomes fromPyarrowFieldParser.from_paimon_schemaand marksPK columns as
NOT NULL. Thebatchfrom the Parquet reader may havethose columns as nullable —
from_batchesdoes a strict schema equalitycheck (including the nullable bit) and rejects the mismatch.
This is a pre-existing issue on master. It was never triggered by
existing tests because they all write multiple snapshots (creating
non-raw-convertible splits that go through the merge-read path, which
preserves nullability).
Linked Issue
Discovered while testing PR #7813 on CI (Python 3.10 / pyarrow in the
CI container triggers the strict check; newer pyarrow on local dev
machines is more lenient).
Fix
Replace the strict
from_batches([batch], schema=schema)with:Table.cast(target_schema)is a zero-copy metadata-only operation fornullable→not-null diffs. It also handles other type promotions (e.g.
large_string → string) that may occur on some Ray versions.When schemas already match, the
ifbranch is skipped — zero overhead.Tests
Added
test_read_paimon_pk_single_snapshot: PK table + single write +read_paimon()— verifies no ArrowInvalid on raw-convertible splits.All existing
ray_integration_test.pytests remain green.API & Format Impact
None. Pure internal fix in the Ray read task function.
Documentation Impact
None.
Generative AI Disclosure
Drafted with Claude Code assistance, reviewed and tested by the author.